<?php
/*
    session_start();

    if(!empty($_SESSION))
    {

        $_SESSION = array();

        session_destroy();

        unset($_SESSION);
        
    }

include 'FUNCTIONS/CONNECTION/connect_bd.php';

$requete = mysql_query("SELECT login_admin, pass_admin FROM ADMIN") or die( mysql_error() );

    if ($requete)
    {

        $donnee = mysql_fetch_array($requete);

        define('LOGIN',$donnee['login_admin']);
        define('PASSWORD',$donnee['pass_admin']);
        $errorMessage = '';

        //echo LOGIN;
        //echo PASSWORD;

    }

    if(!empty($_POST))
    {

        if(!empty($_POST['login']) && !empty($_POST['password']))
        {

            if($_POST['login'] !== LOGIN)
            {
                $errorMessage = 'Mauvais login !';
            }
            elseif($_POST['password'] !== PASSWORD)
            {
                $errorMessage = 'Mauvais password !';
            }
            else
            {
                echo $_POST['login'];
                echo $_POST['password'];

                session_start();

                $_SESSION['login'] = LOGIN;
                header('Location: http://qcm.back.local/accueil.php');

                exit();
            }
        }
        else
        {
            $errorMessage = 'Veuillez inscrire vos identifiants svp !';
        }
    }
 */

if(!empty($_POST))
{
    header('Location: http://qcm.back.local/acceuil.php');
}

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
            <title>QCM PROFESSEUR</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" media="screen" type="text/css" title="index" href="CSS/site.css" />
            <!--[if lte IE 8]>
                    <script type="text/javascript" src="script/roundies.js">
                    </script><![endif]-->
    </head>

    <body class="body_login">
        <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
            <?php
                if(!empty($errorMessage))
                {
                echo '<p>', htmlspecialchars($errorMessage) ,'</p>';
                }
            ?>
            <center>
                <div class="round_corner">
                    <center>
                        <br/>
                        <br/>
                        <table>
                            <tr>
                                <td >
                                    Identifiant :
                                </td>
                                <td>
                                    <input type='text' name='login' size='20'/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Mot de passe :
                                </td>
                                <td>
                                    <input type='password' name='password' size='20'/>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <input type="submit" name="submit" value="Connexion" />
                                </td>
                            </tr>
                        </table>
                    </center>
                </div>
            </center
        </form>
    </body>
</html>
